package com.hippo.javacore.javaiostream.iostream;

import java.io.FileOutputStream;
import java.io.OutputStreamWriter;

/**
 * @ClassName OutputStreamWriterOpt
 * @Description TODO 字符输出转换流操作类
 * @Author tangxl
 * @create 2023-04-07 08:35
 **/
public class OutputStreamWriterOpt {
    public static void main(String[] args) {
        // 字符输出转换流
        try(
                // 创建字符输出转换流对象，指定编码表(`utf-8`, `gbk`, `gb2312`)
                OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("study-commons/java-file-iostream/src/main/resources/file/a.txt",true), "UTF-8");
        ) {
            // 写数据
            osw.write("你好中国");
            osw.write("world");
            osw.write("java");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
